package com.house.framework.controller;


import com.house.exception.MyException;
import com.house.framework.service.IVerifycodeService;
import com.house.framework.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.Map;

/**
 * @ClassName VerifycodeController
 * @Version 1.0
 */
@RestControllerAdvice
@RequestMapping("/verifycode")
public class VerifycodeController {

    @Autowired
    private IVerifycodeService verifycodeService;
    /**
     *@Description Map接收参数
     *@Param
     *@Return
     */
    @PostMapping("/smsCode")
    public AjaxResult smsCode(@RequestBody Map<String, String> param) {
        try {
            verifycodeService.smsCode(param);
            return AjaxResult.me();
        } catch (MyException e) {
            e.printStackTrace();
            return AjaxResult.me().setMsg(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setMsg("系统繁忙，稍后重试...");
        }

    }
}
